home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3153 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  59 lines

  1. Newsgroups: comp.lang.c,gnu.gcc.help
  2. Path: in1.uu.net!tellab5!news
  3. From: Joe Toth <toth@tellabs.com>
  4. Subject: Re: Casting unsigned short as unsigned int -> Bus error
  5. X-Nntp-Posting-Host: sunh25
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <1996Jan26.140949.14999@tellab5.tellabs.com>
  8. Sender: news@tellab5.tellabs.com (News)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Tellabs Operations, Inc.
  11. References: <simmons.820857453@rzdspc1> <820879186snz@genesis.demon.co.uk> <4e8v6t$bd2@crl.crl.com>
  12. Mime-Version: 1.0
  13. Date: Fri, 26 Jan 1996 14:09:49 GMT
  14. X-Mailer: Mozilla 1.1 (X11; U; SunOS 4.1.3 sun4c)
  15. X-Url: news:4e8v6t$bd2@crl.crl.com
  16.  
  17. gherlein@crl.com (Greg Herlein) wrote:
  18. <<<<SNIP>>>>>
  19. >This sounds to me like a problem I had a while back - though I'm not a
  20. >Sparc guru enough to know for sure.  I was reading elements from
  21. >structures like this too, and got bus errors for not reading on 32 bit
  22. >boundaries.  Does it work if you read the myshort variable into a
  23. >short *then* cast it to an unsigned int?  I'm not sure what the order
  24. >of operations is on the assignment... I would think the dererencing of
  25. >the stucture element poinet would be first, but what do I know? 
  26.  
  27. Yep,  I spent a number of weeks trying to fix this problem on some 
  28. code running on Sparcs with SunOS.  Then I checked the man pages on the
  29. Sun Workstation and found the C compiler option;
  30.  
  31.      -misalign Generate code to  allow  loading  and  storage  of
  32.                misaligned data (Sun-4 systems only).
  33.  
  34. End of problems... at least until we have to port the code to
  35. some other system that doesn't like the alignments.
  36.  
  37. >
  38. >Good luck!
  39.  
  40. Ditto....
  41.  
  42. >
  43. >--
  44. >Greg Herlein
  45. >gherlein@crl.com
  46. >http://www.crl.com/www/users/gh/gherlein (under construction, but there!)
  47. >Vallejo, CA
  48.  
  49. -- 
  50.   _  _  ___  --------------------------+---------------------------------
  51.   | / _  |    Joseph G. Toth Jr.       | Tellabs Operations, Inc.  
  52. \_| \_/  |                             | toth@tellabs.com
  53.  
  54. > Every program has at least one bug and can be shortened by at least
  55. > one instruction -- from which, by induction, it is evident that every
  56. > program can be reduced to one instruction that does not work.
  57. >                       -- Ken Arnold
  58.  
  59.